import result from '/@utils/Axios.ts'


//新闻推荐
export function recommendations(){
    return result({
        url: '/api/news/news/recommendation/',
        method: 'get'
    })
}


//新闻分类
export function categories(){
    return result({
        url: '/api/news/news/categories/',
        method: 'get'
    })
}

//排行榜
export function hot_ranking(){
    return result({
        url: '/api/news/news/hot_ranking/',
        method: 'get'
    })
}

//新闻列表
export function news_list(params:any){
    return result({
        url: '/api/news/news/',
        method: 'get',
        params
    })
}




//添加新闻
export function add_news(params:any){
    return result({
        url: '/api/news/news/',
        method: 'post',
        data: params
    })
}
//修改新闻
export function put_news(params:any){
    return result({
        url: '/api/news/news/',
        method: 'put',
        data: params
    })
}

//修改新闻
export function del_news(id:number){
    return result({
        url: `/api/news/news/${id}/`,
        method: 'delete',
    })
}

//新闻详情
export function news_detail(id: number){
    return result({
        url: `/api/news/news/${id}/`,
        method: 'get'
    })
}

//增加浏览次数
export function view_count(id: number){
    return result({
        url: `/api/news/news/view_count/${id}/`,
        method: 'post'
    })
}

export function like(id: number){
    return result({
        url: `/api/news/news/like/${id}/`,
        method: 'post'
    })
}

export function comment_list(params: {news_id: number, page: number, page_size: number}){
    return result({
        url: `/api/news/comments/`,
        method: 'get',
        params
    })
}

export function comment_create(data:any){
    return result({
        url: `/api/news/comments/`,
        method: 'post',
        data
    })
}

export function comment_like(id: number){
    return result({
        url: `/api/news/comments/like/${id}/`,
        method: 'post' 
    }) 
}

export function notifications_list(params: {page: number, page_size: number}){
    return result({
        url: `/api/news/news/notifications/`,
        method: 'get',
        params
    }) 
}

export function notifications_read(data: any){
    return result({
        url: `/api/news/news/notifications/`,
        method: 'post',
        data
    })
}